﻿#coding: utf-8

require 'dm-validations'
require 'dm-types'
require 'json'

class Content
	include DataMapper::Resource

	property :id, Serial
	property :text, Text
	property :movie, FilePath
	property :music, FilePath
	property :image, FilePath
	property :qrcode, FilePath
	property :lat, Float
	property :long, Float
	property :street, Text
	property :postal_code, Integer 
	property :town, Text
	property :phone, Text
	property :history, Text
	property :website, FilePath
	property :created_at, Time
	property :updated_at, Time

	belongs_to :node

	def to_json(*a)
		{			
			'text' => text.to_s,
			'movie' => movie.to_s,
			'music' => music.to_s,
			'image' => image.to_s,
			'qrcode' => qrcode.to_s,
			'lat' => lat.to_f,
			'long' => long.to_f,
			'street' => street.to_s,
			'postal_code' => postal_code.to_i,
			'town' => town.to_s,
			'phone' => phone.to_s,
			'history' => history.to_s,
			'website' => website.to_s,			
			'created_at' => created_at.to_i,
			'updated_at' => updated_at.to_i
		}.to_json(*a)
	end
end
